import SdkManager from "../ZsSdk/SdkManager";
import SdkUIBase from "../ZsSdk/SdkUIBase";
import PropManager from "./PropManager";
import SoundManager from "./SoundManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class MainUI extends SdkUIBase{
    protected async onLoad() {
        super.onLoad();
        SdkManager.Instance().init();
        SoundManager.getInstance().init();
        this.getChild("btn_gift").active = SdkManager.Instance().isShowSidebar();
        await SdkManager.Instance().isErroAction();
        PropManager.getInstance().init();
    }

    private settingClickCb() {
        this.getChild("SettingDialog").active = true;
    }

    // 分享
    private shareClickCb() {
        SdkManager.Instance().share(() => { });
    }

    // 侧边栏
    private giftClickCb() {
        // 显示奖励UI
        SdkManager.Instance().showSidebarRewardDialog(() => {
            this.getChild("btn_gift").active = false;
            // UIManager.getInstance().showFloatTip("已获得奖励!");
            PropManager.getInstance().setPropNum(1, 1);
            console.log("领取奖励");
        });
    }

    //开始游戏
    private startClickCb() {
        cc.director.loadScene("game");
        SdkManager.Instance().showInterstitialAd();
    }
}
